#ifndef MATHTOOLS_PLANE_H_
#define MATHTOOLS_PLANE_H_

#include "Vector3D.h"

namespace math_tools
{
	// Representation of plane in 3D space, defined by one point and a normal vector.
	class Plane
	{
	public:

		Plane();
		Plane(const Vector3D & position, const Vector3D & normal);

		virtual ~Plane();

		// Returns the closest point from the given point in space.
		Vector3D closestPoint(const Vector3D & point);

		// Returns the distance from the given point int space.
		double distanceFrom(const Vector3D & point);

		// Returns the squared distance from the given point int space.
		// Used for optimalization purposes.
		double distanceFromSqr(const Vector3D & point);

		// Getters:
		inline const Vector3D & getNormal() const
		{
			return normal_;
		}

		inline const Vector3D & getPosition() const
		{
			return position_;
		}

		// Setters:
		inline void setNormal(const Vector3D & normal)
		{
			normal_ = normal;
			normal_.unit();
		}

		inline void setPosition(const Vector3D & position_)
		{
			this->position_ = position_;
		}

	private:

		Vector3D position_;
		Vector3D normal_;
	};
}
#endif
